THREE.DepthDef = {
uniforms: {
    tdeep : { type: "t", value: null },
    offset : { type: "v2", value: new THREE.Vector2() },
    range : { type: "v2", value: new THREE.Vector2() },
    uDisplacementBias: { type: "f", value: -3.0 },
    uDisplacementScale: { type: "f", value: 6.0 }
},
vertexShader: [
"uniform sampler2D tdeep;",
"uniform float uDisplacementScale;",
"uniform float uDisplacementBias;",
"uniform vec2 offset;",
"uniform vec2 range;",
"varying vec2 vUv2;",
THREE.ShaderChunk[ 'morphtarget_pars_vertex' ],
THREE.ShaderChunk[ 'skinning_pars_vertex' ],
THREE.ShaderChunk[ 'logdepthbuf_pars_vertex' ],
'void main() {',
	THREE.ShaderChunk[ 'skinbase_vertex' ],
	THREE.ShaderChunk[ 'morphtarget_vertex' ],
	THREE.ShaderChunk[ 'skinning_vertex' ],
	THREE.ShaderChunk[ 'default_vertex' ],
	"#ifdef USE_SKINNING",
	'gl_Position = projectionMatrix * mvPosition;',
	"#else",
	"vUv2 = (vec2(position.x, position.z)+offset)/range;",
    "vUv2.y = 1.0-vUv2.y;",
    "vec3 dv = texture2D( tdeep, vUv2 ).xyz;",
    "float df = (uDisplacementScale * dv.x) + uDisplacementBias;",
    "vec3 displacedPosition = position;",
    "displacedPosition.y += df;",
    "gl_Position = projectionMatrix * modelViewMatrix * vec4(displacedPosition,1.0);",
    "#endif",
	THREE.ShaderChunk[ 'logdepthbuf_vertex' ],
'}'
].join('\n'),
fragmentShader: [
THREE.ShaderChunk[ 'logdepthbuf_pars_fragment' ],
'vec4 pack_depth( const in float depth ) {',
'	const vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );',
'	const vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );',
'	vec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );', // '	vec4 res = fract( depth * bit_shift );',
'	res -= res.xxyz * bit_mask;',
'	return res;',
'}',
'void main() {',
	THREE.ShaderChunk[ 'logdepthbuf_fragment' ],
'	#ifdef USE_LOGDEPTHBUF_EXT',
'		gl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );',
'	#else',
'		gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );',
'	#endif',
	//'gl_FragData[ 0 ] = pack_depth( gl_FragCoord.z / gl_FragCoord.w );',
	//'float z = ( ( gl_FragCoord.z / gl_FragCoord.w ) - 3.0 ) / ( 4000.0 - 3.0 );',
	//'gl_FragData[ 0 ] = pack_depth( z );',
	//'gl_FragData[ 0 ] = vec4( z, z, z, 1.0 );',
'}'
].join('\n')
}